package com.sneakxy.mybase4j.platform.beans;

import javax.validation.constraints.Size;

import org.hibernate.validator.constraints.NotBlank;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;

import com.sneakxy.mybase4j.base.bean.BaseEntity;
import com.sneakxy.mybase4j.base.bean.TimeEntity;
import com.sneakxy.mybase4j.base.bean.ValidAdd;
import com.sneakxy.mybase4j.base.bean.ValidEdit;
import com.sneakxy.mybatis.commons.annotations.Column;
import com.sneakxy.mybatis.commons.annotations.Table;
import com.sneakxy.mybatis.commons.orm.generation.GeneratedValue;
import com.sneakxy.mybatis.commons.orm.generation.GenerationType;

/**
 * 
 * @author 潜行的青衣
 * @see
 */
@Table("t_mb4j_role")
public class Role extends BaseEntity<String> implements TimeEntity {

	private final static long serialVersionUID = -1L;

	@Id
	@Column("id")
	@GeneratedValue(strategy = GenerationType.MANUAL)
	@NotBlank(groups={ValidAdd.class, ValidEdit.class})
	@Size(max=32, groups={ValidAdd.class, ValidEdit.class})
	private String id;

	@Column("name")
	@NotBlank(groups={ValidAdd.class, ValidEdit.class})
	@Size(max=50, groups={ValidAdd.class, ValidEdit.class})
	private String name;

	@Column("memo")
	@Size(max=100, groups={ValidAdd.class, ValidEdit.class})
	private String memo;

	@Column("sort")
	private Integer sort;

	@Column("createtime")
	private String createtime;

	@Column("updatetime")
	private String updatetime;

	@Transient
	private boolean isNew;

	/* (non-Javadoc)
	 * @see com.sneakxy.mybase4j.base.bean.BaseEntity#isNew()
	 */
	@Override
	public boolean isNew() {
		return isNew || super.isNew();
	}

	/**
	 * @param isNew the isNew to set
	 */
	public void setNew(boolean isNew) {
		this.isNew = isNew;
	}
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getMemo() {
		return memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}

	public Integer getSort() {
		return sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}

	public String getCreatetime() {
		return createtime;
	}

	public void setCreatetime(String createtime) {
		this.createtime = createtime;
	}

	public String getUpdatetime() {
		return updatetime;
	}

	public void setUpdatetime(String updatetime) {
		this.updatetime = updatetime;
	}

}
